package com.huawei.appgallery.payzone.ui;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.MenuItem;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.huawei.appgallery.assistantdock.base.externalaction.openviewaction.RemoteBuoyAction;
import com.huawei.appgallery.foundation.service.common.protocol.AppListFragmentProtocol;
import com.huawei.appgallery.foundation.service.common.protocol.request.AppListFragmentRequest;
import com.huawei.appgallery.foundation.ui.framework.activity.BaseActivity;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseDetailResponse.ShareInfo;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.TaskFragment;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.TaskFragment.e;
import com.huawei.appgallery.foundation.ui.framework.titleframe.bean.BaseTitleBean;
import com.huawei.appgallery.foundation.ui.framework.titleframe.bean.SpinnerItem;
import com.huawei.appgallery.foundation.ui.framework.uikit.ContractFragment;
import com.huawei.appgallery.payzone.api.IPayZoneActivityProtocol;
import com.huawei.hmf.annotation.ActivityDefine;
import com.huawei.secure.android.common.intent.SafeBundle;
import java.util.List;
import o.cdh;
import o.cfv;
import o.chm;
import o.cin;
import o.cir;
import o.cjd;
import o.cje;
import o.cjf;
import o.cjk;
import o.cjl;
import o.cjm;
import o.cjo;
import o.crb.a;
import o.crb.c;
import o.crc;
import o.cri;
import o.cvt;
import o.djb;
import o.djf;
import o.epr;
import o.fiv;
import o.FragmentTransaction;

@ActivityDefine(alias = "PayZoneActivity", protocol = IPayZoneActivityProtocol.class)
public class PayZoneActivity extends BaseActivity implements e, djb {
    private fiv ˏॱ = fiv.ॱ(this);
    private String ͺ;
    private String ॱˊ;

    static {
        cjl.ˋ("paymentapplist.fragment", PaymentAppListFragment.class);
    }

    public void onCreate(@Nullable Bundle bundle) {
        super.onCreate(bundle);
        cri.ॱ();
        chm.ॱ().ˋ();
        setContentView(a.ॱ);
        ॱ(getString(c.ˏ));
        Bundle bundle2;
        Fragment ˊ;
        if (bundle == null) {
            String payid;
            IPayZoneActivityProtocol iPayZoneActivityProtocol = (IPayZoneActivityProtocol) this.ˏॱ.ॱ();
            this.ͺ = iPayZoneActivityProtocol != null ? iPayZoneActivityProtocol.getUri() : null;
            if (iPayZoneActivityProtocol != null) {
                payid = iPayZoneActivityProtocol.getPayid();
            } else {
                payid = null;
            }
            this.ॱˊ = payid;
            if (this.ͺ != null) {
                bundle2 = new Bundle();
                bundle2.putString(RemoteBuoyAction.REMOTE_BUOY_URI, this.ͺ);
                bundle2.putString("payid", this.ॱˊ);
                ˊ = cjk.ˎ().ˊ(new cjm("loading.fragment", null));
                if (ˊ instanceof TaskFragment) {
                    TaskFragment taskFragment = (TaskFragment) ˊ;
                    taskFragment.ʼ(bundle2);
                    taskFragment.ˋ(ˏॱ(), b.ˎ, "TaskFragment");
                    return;
                }
                return;
            }
            crc.ॱ.ˊ("PayZoneActivity", "PayZone's uri is null!");
            finish();
            return;
        }
        bundle2 = new Bundle();
        this.ͺ = bundle.getString("AppDetailActivity.Card.URI");
        this.ॱˊ = bundle.getString("payid");
        bundle2.putString(RemoteBuoyAction.REMOTE_BUOY_URI, this.ͺ);
        bundle2.putString("payid", this.ॱˊ);
        ˊ = cjk.ˎ().ˊ(new cjm("loading.fragment", null));
        if (ˊ instanceof TaskFragment) {
            taskFragment = (TaskFragment) ˊ;
            taskFragment.ʼ(bundle2);
            taskFragment.ˋ(ˏॱ(), b.ˎ, "TaskFragment");
        }
    }

    public void onSaveInstanceState(Bundle bundle) {
        if (!TextUtils.isEmpty(this.ͺ)) {
            bundle.putString("AppDetailActivity.Card.URI", this.ͺ);
            bundle.putString("payid", this.ॱˊ);
            super.onSaveInstanceState(bundle);
        }
    }

    public void onDestroy() {
        epr.ˎ().ˎ(null);
        super.onDestroy();
    }

    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (4 == keyEvent.getKeyCode()) {
            finish();
        }
        return false;
    }

    public boolean ˋ(TaskFragment taskFragment, TaskFragment.b bVar) {
        if (bVar.ˋ.getResponseCode() == 0 && bVar.ˋ.getRtnCode_() == 0) {
            SafeBundle safeBundle = new SafeBundle(taskFragment.ˊॱ());
            String string = safeBundle.getString(RemoteBuoyAction.REMOTE_BUOY_URI);
            String string2 = safeBundle.getString("trace_id");
            AppListFragmentRequest appListFragmentRequest = new AppListFragmentRequest();
            appListFragmentRequest.ˋ(string);
            appListFragmentRequest.ˊ(string2);
            appListFragmentRequest.ॱ(1);
            appListFragmentRequest.ˊ(0);
            appListFragmentRequest.ˊ(false);
            cjo appListFragmentProtocol = new AppListFragmentProtocol();
            appListFragmentProtocol.ˏ(appListFragmentRequest);
            ContractFragment contractFragment = (ContractFragment) cjk.ˎ().ˊ(new cjm("paymentapplist.fragment", appListFragmentProtocol));
            if (contractFragment.ˊ(cin.class) != null) {
                ((cin) contractFragment).ॱ(bVar);
            }
            FragmentTransaction ˊ = ˏॱ().ˊ();
            ˊ.ˏ(b.ˎ, contractFragment, "AppDetail");
            ˊ.ˋ();
            return true;
        }
        if (taskFragment != null) {
            cir o_cir = (cir) taskFragment.ˊ(cir.class);
            if (o_cir != null) {
                o_cir.ॱ(bVar.ˋ.getResponseCode(), true);
            }
        }
        return false;
    }

    public void ˎ(TaskFragment taskFragment, List<cvt> list) {
        SafeBundle safeBundle = new SafeBundle(taskFragment.ˊॱ());
        list.add(cfv.ˎ(safeBundle.getString(RemoteBuoyAction.REMOTE_BUOY_URI), safeBundle.getString("trace_id"), cdh.ˎ(this), 1));
    }

    public String ʿ() {
        return this.ͺ;
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() != 16908332) {
            return super.onOptionsItemSelected(menuItem);
        }
        finish();
        return true;
    }

    public cjf ˊ(String str) {
        BaseTitleBean baseTitleBean = new BaseTitleBean();
        baseTitleBean.ॱ(str);
        cje o_cje = new cje();
        o_cje.ˎ(baseTitleBean);
        o_cje.ˋ("back_title_searchbtn");
        cjf ˋ = cjd.ˋ(this, o_cje);
        if (ˋ != null) {
            ˋ.ॱ((djb) this);
        }
        return ˋ;
    }

    public void ˊ(SpinnerItem spinnerItem) {
    }

    public void ʼʽ() {
        djf.ˋ(this, "", null);
    }

    public void ˋ(ShareInfo shareInfo) {
    }
}
